/**
 * Metaphase Editor - WYSIWYG HTML Editor Component
 * Copyright (C) 2010  Rudolf Visagie
 * Full text of license can be found in com/metaphaseeditor/LICENSE.txt
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * The author can be contacted at metaphase.editor@gmail.com.
 */

package com.metaphaseeditor;

import java.awt.FlowLayout;
import javax.swing.JOptionPane;

/**
 *
 * @author Rudolf Visagie
 */
public class LinkDialog extends javax.swing.JDialog {

    //TODO: other targets
    //TODO: test
    public enum LinkType {
        URL("URL"),
        LINK_TO_ANCHOR_IN_TEXT("Link to Anchor in Text"),
        EMAIL("E-mail");

        private String text;

        LinkType(String text) {
            this.text = text;
        }

        public String getText() {
            return text;
        }

        @Override
        public String toString() {
            return text;
        }
    }

    private String html = null;
    
    private UrlLinkPanel urlLinkPanel = new UrlLinkPanel();
    private EmailLinkPanel emailLinkPanel = new EmailLinkPanel();
    private AnchorLinkPanel anchorLinkPanel = new AnchorLinkPanel();
    
    /** Creates new form LinkDialog */
    public LinkDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        setIconImage(new javax.swing.ImageIcon(getClass().getResource("/com/metaphaseeditor/icons/metaphase16x16.png")).getImage());       

        setLocationRelativeTo(null);
        mainPanel.setLayout(new FlowLayout());
        mainPanel.add(urlLinkPanel);

        linkTypeComboBox.removeAllItems();
        LinkType[] linkTypes = LinkType.values();
        for (int i=0; i<linkTypes.length; i++) {
            linkTypeComboBox.addItem(linkTypes[i]);
        }

        languageDirectionComboBox.removeAllItems();
        LanguageDirection[] languageDirections = LanguageDirection.values();
        for (int i=0; i<languageDirections.length; i++) {
            languageDirectionComboBox.addItem(languageDirections[i]);
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainTabbedPane = new javax.swing.JTabbedPane();
        linkInfoPanel = new javax.swing.JPanel();
        linkTypeLabel = new javax.swing.JLabel();
        linkTypeComboBox = new javax.swing.JComboBox();
        mainPanel = new javax.swing.JPanel();
        advancedPanel = new javax.swing.JPanel();
        idLabel = new javax.swing.JLabel();
        idTextField = new javax.swing.JTextField();
        styleClassesLabel = new javax.swing.JLabel();
        styleClassesTextField = new javax.swing.JTextField();
        styleLabel = new javax.swing.JLabel();
        styleTextField = new javax.swing.JTextField();
        advisoryTitleLabel = new javax.swing.JLabel();
        advisoryTitleTextField = new javax.swing.JTextField();
        languageDirectionLabel = new javax.swing.JLabel();
        languageDirectionComboBox = new javax.swing.JComboBox();
        languageCodeLabel = new javax.swing.JLabel();
        languageCodeTextField = new javax.swing.JTextField();
        advisoryContentTypeLabel = new javax.swing.JLabel();
        advisoryContentTypeTextField = new javax.swing.JTextField();
        accessKeyLabel = new javax.swing.JLabel();
        accessKeyTextField = new javax.swing.JTextField();
        tabIndexLabel = new javax.swing.JLabel();
        tabIndexSpinner = new javax.swing.JSpinner();
        linkedResourceCharsetLabel = new javax.swing.JLabel();
        linkedResourceCharsetTextField = new javax.swing.JTextField();
        tabIndexToggleButton = new javax.swing.JToggleButton();
        okButton = new javax.swing.JButton();
        cancelButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Link");

        linkTypeLabel.setText("Link Type");

        linkTypeComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "URL" }));
        linkTypeComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                linkTypeComboBoxActionPerformed(evt);
            }
        });

        mainPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 381, Short.MAX_VALUE)
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 311, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout linkInfoPanelLayout = new javax.swing.GroupLayout(linkInfoPanel);
        linkInfoPanel.setLayout(linkInfoPanelLayout);
        linkInfoPanelLayout.setHorizontalGroup(
            linkInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(linkInfoPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(linkInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(linkInfoPanelLayout.createSequentialGroup()
                        .addComponent(linkTypeLabel)
                        .addGap(18, 18, 18)
                        .addComponent(linkTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        linkInfoPanelLayout.setVerticalGroup(
            linkInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(linkInfoPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(linkInfoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(linkTypeLabel)
                    .addComponent(linkTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        mainTabbedPane.addTab("Link Info", linkInfoPanel);

        idLabel.setText("ID");

        styleClassesLabel.setText("Style Classes");

        styleLabel.setText("Style");

        advisoryTitleLabel.setText("Advisory Title");

        languageDirectionLabel.setText("Language Direction");

        languageDirectionComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "None", "Left to Right", "Right to Left" }));

        languageCodeLabel.setText("Language Code");

        advisoryContentTypeLabel.setText("Advisory Content Type");

        accessKeyLabel.setText("Access Key");

        tabIndexLabel.setText("Tab Index");

        tabIndexSpinner.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(0), Integer.valueOf(0), null, Integer.valueOf(1)));
        tabIndexSpinner.setEnabled(false);

        linkedResourceCharsetLabel.setText("Linked Resource Charset");

        tabIndexToggleButton.setSelected(true);
        tabIndexToggleButton.setText("Default");
        tabIndexToggleButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tabIndexToggleButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout advancedPanelLayout = new javax.swing.GroupLayout(advancedPanel);
        advancedPanel.setLayout(advancedPanelLayout);
        advancedPanelLayout.setHorizontalGroup(
            advancedPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(advancedPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(advancedPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(linkedResourceCharsetLabel)
                    .addComponent(advisoryContentTypeLabel)
                    .addComponent(advisoryTitleLabel)
                    .addComponent(styleClassesLabel)
                    .addComponent(styleLabel)
                    .addComponent(idLabel)
                    .addComponent(languageDirectionLabel)
                    .addComponent(languageCodeLabel)
                    .addComponent(accessKeyLabel)
                    .addComponent(tabIndexLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(advancedPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(languageCodeTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE)
                    .addComponent(languageDirectionComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(idTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE)
                    .addComponent(styleTextField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE)
                    .addComponent(styleClassesTextField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE)
                    .addComponent(advisoryTitleTextField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE)
                    .addComponent(advisoryContentTypeTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE)
                    .addComponent(linkedResourceCharsetTextField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE)
                    .addGroup(advancedPanelLayout.createSequentialGroup()
                        .addComponent(tabIndexSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(tabIndexToggleButton))
                    .addComponent(accessKeyTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        advancedPanelLayout.setVerticalGroup(
            advancedPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(advancedPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(advancedPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(idLabel)
                    .addComponent(idTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(advancedPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(styleClassesLabel)
                    .addComponent(styleClassesTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(8, 8, 8)
                .addGroup(advancedPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(styleTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(styleLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(advancedPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(advisoryTitleTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(advisoryTitleLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(advancedPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(advisoryContentTypeLabel)
                    .addComponent(advisoryContentTypeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(advancedPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(languageDirectionLabel)
                    .addComponent(languageDirectionComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(advancedPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(languageCodeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(languageCodeLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(advancedPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(accessKeyLabel)
                    .addComponent(accessKeyTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(advancedPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tabIndexLabel)
                    .addComponent(tabIndexSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tabIndexToggleButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(advancedPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(linkedResourceCharsetLabel)
                    .addComponent(linkedResourceCharsetTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(93, Short.MAX_VALUE))
        );

        mainTabbedPane.addTab("Advanced", advancedPanel);

        okButton.setText("OK");
        okButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okButtonActionPerformed(evt);
            }
        });

        cancelButton.setText("Cancel");
        cancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(264, Short.MAX_VALUE)
                .addComponent(okButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cancelButton)
                .addContainerGap())
            .addComponent(mainTabbedPane)
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {cancelButton, okButton});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(mainTabbedPane, javax.swing.GroupLayout.PREFERRED_SIZE, 391, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cancelButton)
                    .addComponent(okButton))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
        LinkType linkType = (LinkType)linkTypeComboBox.getSelectedItem();
        
        String id = idTextField.getText();
        String styleClasses = styleClassesTextField.getText();
        String style = styleTextField.getText();
        String advisoryTitle = advisoryTitleTextField.getText();
        String advisoryContentType = advisoryContentTypeTextField.getText();
        LanguageDirection languageDirection = (LanguageDirection)languageDirectionComboBox.getSelectedItem();
        String languageCode = languageCodeTextField.getText();
        String accessKey = accessKeyTextField.getText();
        Integer tabIndex = (Integer)tabIndexSpinner.getValue();
        String charSet = linkedResourceCharsetTextField.getText();

        StringBuffer buffer = new StringBuffer();
        String linkText = null;
        switch (linkType) {
            case URL:
                String url = urlLinkPanel.getUrl();
                LinkTarget linkTarget = urlLinkPanel.getLinkTarget();

                if (url.length() == 0) {
                    JOptionPane.showMessageDialog(null, "The link URL must be specified.", "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                }

                buffer.append("<a href='");
                buffer.append(url);
                buffer.append("'");

                if (linkTarget.getAttrValue() != null) {
                    buffer.append(" target='");
                    buffer.append(linkTarget.getAttrValue());
                    buffer.append("'");
                }

                linkText = url;
                break;
                
            case LINK_TO_ANCHOR_IN_TEXT:
                String anchorName = anchorLinkPanel.getAnchorName();

                if (anchorName.length() == 0) {
                    JOptionPane.showMessageDialog(null, "The anchor name must be specified.", "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                }

                buffer.append("<a href='#");
                buffer.append(anchorName);
                buffer.append("'");

                linkText = "#" + anchorName;
                break;
            case EMAIL:
                String emailAddress = emailLinkPanel.getEmailAddress();
                String messageSubject = emailLinkPanel.getMessageSubject();
                String messageBody = emailLinkPanel.getMessageBody();

                if (emailAddress.length() == 0) {
                    JOptionPane.showMessageDialog(null, "The e-mail address must be specified.", "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                }

                buffer.append("<a href='mailto:");
                buffer.append(emailAddress);
                if (messageSubject.length() > 0 || messageBody.length() > 0) {
                    buffer.append('?');
                }
                if (messageSubject.length() > 0) {
                    buffer.append("subject=");
                    buffer.append(messageSubject);
                    buffer.append("&amp;");
                }
                if (messageBody.length() > 0) {
                    buffer.append("body=");
                    buffer.append(messageBody);
                }
                buffer.append("'");
                linkText = "mailto:" + emailAddress;
                break;
        }        
        
        if (id.length() > 0) {
            buffer.append(" id='");
            buffer.append(id);
            buffer.append("'");
        }        
        if (styleClasses.length() > 0) {
            buffer.append(" class='");
            buffer.append(styleClasses);
            buffer.append("'");
        }
        if (style.length() > 0) {
            buffer.append(" style='");
            buffer.append(style);
            buffer.append("'");
        }
        if (advisoryTitle.length() > 0) {
            buffer.append(" title='");
            buffer.append(advisoryTitle);
            buffer.append("'");
        }
        if (advisoryContentType.length() > 0) {
            buffer.append(" type='");
            buffer.append(advisoryContentType);
            buffer.append("'");
        }
        if (languageCode.length() > 0) {
            buffer.append(" lang='");
            buffer.append(languageCode);
            buffer.append("'");
        }
        if (languageDirection.getAttrValue() != null) {
            buffer.append(" dir='");
            buffer.append(languageDirection.getAttrValue());
            buffer.append("'");
        }
        if (accessKey.length() > 0) {
            buffer.append(" accesskey='");
            buffer.append(accessKey);
            buffer.append("'");
        }
        if (!tabIndexToggleButton.isSelected()) {
            buffer.append(" tabindex='");
            buffer.append(tabIndex);
            buffer.append("'");
        }
        if (charSet.length() > 0) {
            buffer.append(" charset='");
            buffer.append(charSet);
            buffer.append("'");
        }
        buffer.append(">");
        buffer.append(linkText);
        buffer.append("</a>");

        html = buffer.toString();
        setVisible(false);
}//GEN-LAST:event_okButtonActionPerformed

    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
        setVisible(false);
}//GEN-LAST:event_cancelButtonActionPerformed

    private void linkTypeComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_linkTypeComboBoxActionPerformed
        LinkType linkType = (LinkType)linkTypeComboBox.getSelectedItem();
        mainPanel.removeAll();
        if (linkType == LinkType.URL) {            
            mainPanel.add(urlLinkPanel);
        } else if (linkType == LinkType.LINK_TO_ANCHOR_IN_TEXT) {
            mainPanel.add(anchorLinkPanel);
        } else if (linkType == LinkType.EMAIL) {            
            mainPanel.add(emailLinkPanel);            
        }
        pack();
    }//GEN-LAST:event_linkTypeComboBoxActionPerformed

    private void tabIndexToggleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tabIndexToggleButtonActionPerformed
        tabIndexSpinner.setEnabled(!tabIndexSpinner.isEnabled());
    }//GEN-LAST:event_tabIndexToggleButtonActionPerformed

    public String showDialog() {
        setVisible(true);
        return html;
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel accessKeyLabel;
    private javax.swing.JTextField accessKeyTextField;
    private javax.swing.JPanel advancedPanel;
    private javax.swing.JLabel advisoryContentTypeLabel;
    private javax.swing.JTextField advisoryContentTypeTextField;
    private javax.swing.JLabel advisoryTitleLabel;
    private javax.swing.JTextField advisoryTitleTextField;
    private javax.swing.JButton cancelButton;
    private javax.swing.JLabel idLabel;
    private javax.swing.JTextField idTextField;
    private javax.swing.JLabel languageCodeLabel;
    private javax.swing.JTextField languageCodeTextField;
    private javax.swing.JComboBox languageDirectionComboBox;
    private javax.swing.JLabel languageDirectionLabel;
    private javax.swing.JPanel linkInfoPanel;
    private javax.swing.JComboBox linkTypeComboBox;
    private javax.swing.JLabel linkTypeLabel;
    private javax.swing.JLabel linkedResourceCharsetLabel;
    private javax.swing.JTextField linkedResourceCharsetTextField;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JTabbedPane mainTabbedPane;
    private javax.swing.JButton okButton;
    private javax.swing.JLabel styleClassesLabel;
    private javax.swing.JTextField styleClassesTextField;
    private javax.swing.JLabel styleLabel;
    private javax.swing.JTextField styleTextField;
    private javax.swing.JLabel tabIndexLabel;
    private javax.swing.JSpinner tabIndexSpinner;
    private javax.swing.JToggleButton tabIndexToggleButton;
    // End of variables declaration//GEN-END:variables

}
